package com.bz.portal.feign.fallback;

import com.bz.pojo.TbItem;
import com.bz.pojo.TbItemDesc;
import com.bz.pojo.TbItemParamItem;
import com.bz.portal.feign.CommonRedisFeignClient;
import com.bz.vo.CatVo;
import com.bz.vo.ContentVo;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * CommonContent 服务器 - openfeign 降级处理
 * 注意：实现服务降级后，db操作失败，将不会抛出异常，也就是说不会抛出异常，事务就不会生效，这时候可以手动判断抛出异常
 */
@Component
public class CommonRedisFeignClientFallbackFactory implements FallbackFactory<CommonRedisFeignClient> {
    @Override
    public CommonRedisFeignClient create(Throwable throwable) {
        return new CommonRedisFeignClient() {
            @Override
            public CatVo insertItemCategory(CatVo catVo) {
                return null;
            }

            @Override
            public CatVo selectItemCategory() {
                return null;
            }

            @Override
            public void insertContentAD(List<ContentVo> contentVoList) {

            }

            @Override
            public List<ContentVo> selectContentAD() {
                return null;
            }

            @Override
            public void insertItemBasicInfo(TbItem tbItem) {

            }

            @Override
            public TbItem selectItemBasicInfo(Long tbItemId) {
                return null;
            }

            @Override
            public void insertItemDesc(TbItemDesc tbItemDesc) {

            }

            @Override
            public TbItemDesc selectItemDesc(Long tbItemId) {
                return null;
            }

            @Override
            public void insertItemParamItem(TbItemParamItem tbItemParamItem) {

            }

            @Override
            public TbItemParamItem selectItemParamItem(Long tbItemId) {
                return null;
            }
        };
    }
}
